package com.linzx.markdown.processer.impl;

import com.linzx.markdown.processer.Processer;
import com.linzx.markdown.processer.SourceNoteData;
import freemarker.template.Template;
import freemarker.template.TemplateException;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.io.Writer;

/**
 * @author avicomlin
 * @Description:
 * @date 2021/1/18
 */
public abstract class AbstractProcesser implements Processer {
    protected abstract Template getTemplate() throws IOException;
    protected abstract Object getModel(SourceNoteData data);
    protected abstract Writer getWriter(SourceNoteData data) throws Exception;


    @Override
    public final void processor(SourceNoteData data) throws Exception {

        Template template = getTemplate();
        Object model = getModel(data);
        Writer writer = getWriter(data);
        template.process(model,writer);
    }
}
